/*
 * IBM Corporation.
 * Copyright (c) 2014 All Rights Reserved.
 */
package com.xxl.job.admin.rest;

import java.util.Map;

import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;

import com.ibm.risk.common.rest.RestService;
import com.xxl.job.admin.core.model.JobRegistry;
import com.xxl.job.admin.dao.IJobRegistryDao;
import com.xxl.job.admin.service.IJobService;
import com.xxl.job.core.biz.model.ReturnT;

/**
 * 类作用：
 * @author Johnny@cn.ibm.com
 * 使用说明：
 */
@RestService
@Path("/jobregs")
@Produces(MediaType.APPLICATION_JSON)
public class JobRegistryResource {
	@Inject
	IJobRegistryDao dao;
	@Inject
	private IJobService xxlJobService;

	@Path("/triggerChartDate")
	@GET
	public ReturnT<Map<String, Object>> triggerChartDate() {
		ReturnT<Map<String, Object>> triggerChartDate = xxlJobService.triggerChartDate();
		return triggerChartDate;
	}
	@Path(value = "/registry")
	@PUT
	public ResponseEntity<String> registryJob(@RequestBody JobRegistry jobReg) {

		dao.registry(jobReg);
		return new ResponseEntity<String>("Registered", HttpStatus.OK);
	}
}
